<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>有趣</title>
[% include ../pagelets/lib.html %]
</head>
<body>
[% include ../pagelets/head.html %]
<div id="waterfall" class="wrapper waterfall">
    [% include ./pagelets/mediaList.html %]
</div>
<script type="text/temp" id="waterfall_temp">
    <% data.forEach(function(item,index){ %>
    <div class="box">
        <div class="mod">
            <div class="bd">
                <div class="cover"><a href="/pin/<%- item._id %>"><img src="<%- item.mediaCover %>" width="200" height="<%- ejs.filters.getCoverViewHeight(200,item.mediaCoverWidth,item.mediaCoverHeight) %>" alt="<%- item.title %>" /></a></div>
                <div class="title"><%- item.title %></div>
            </div>
            <div class="ft">
                <div class="why"><a href="#"><%-item.author.username%></a>认为这个<%- ejs.filters.getMediaTypeText(item.mediaType) %>很有趣</div>
                <% if(item.source){ %><div class="via"><span>via&nbsp;:&nbsp;</span><a href="<%- item.source %>" target="_blank"><%- item.sourceName %></a></div><% } %>
                <div class="time"><%- ejs.filters.getItemCreateTime(item._id) %></div>
            </div>
        </div>
    </div>
    <% }) %>
</script>
<script src="//lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<script src="[%- staticDomain %]/js/waterfall.js?t=[%- staticVersion %]"></script>
<script src="[%- staticDomain %]/js/ejs.js"></script>
<script>
    ejs.filters.getCoverViewHeight = function(viewWidth, width, height) {
        return Math.floor(viewWidth / width * height);
    };
    ejs.filters.getItemCreateTime = function(objectId) {
        var str = objectId.toString().slice(0, 8);
        var time = parseInt(str, 16) * 1000;
        var date = new Date(time);
        return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
    };
    ejs.filters.getMediaTypeText = function(type) {
        var obj = {
            'video' : '视频',
            'image' : '图片',
            'music' : '音乐'
        };
        return obj[type];
    }
</script>
[% include ../pagelets/foot.html %]
</body>
</html>